//
//  AppDelegate.swift
//  NMPO
//
//  Created by PowerfullClean on 2023/10/25.
//

import UIKit

@main
class NMPOAppDelegate: UIResponder, UIApplicationDelegate {



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        NMPOManager.nmpo_manager.nmpo_createDataBase()
        NMPOManager.nmpo_manager.nmpo_vpnList1Request()
        NMPOManager.nmpo_manager.nmpo_vpnList2Request()
        nmpo_window?.backgroundColor = .white
        nmpo_window?.rootViewController = UINavigationController(rootViewController: NMPOLaunchViewController())
        nmpo_window?.makeKeyAndVisible()
        UIDevice.current.isBatteryMonitoringEnabled = true
        return true
    }
    //MARK: - nmpo action
    func nmpo_refreshMainVC() {
        nmpo_window?.rootViewController = nmpo_tabBarController
        nmpo_window?.makeKeyAndVisible()
//        NMPOManager.nmpo_manager.nmpo_startSpeedScanPing()
    }
    func applicationWillTerminate(_ application: UIApplication) {
        // 关闭应用，使用当前管理类关闭连接
        NMPOManager.nmpo_manager.nmpo_vpnManager?.connection.stopVPNTunnel()
    }
    //MARK: - nmpo lazy
    lazy var nmpo_tabBarController: NMPOTabBarViewController = {
        let nmpo_tabBarController = NMPOTabBarViewController()
        nmpo_tabBarController.nmpo_createChildVC(nmpo_controllers: [NMPOHomeViewController(), NMPOFuncViewController()])
        return nmpo_tabBarController
    }()
    @objc lazy var nmpo_window: UIWindow? = {
        return UIWindow(frame: UIScreen.main.bounds)
    }()
    
    @objc class func nmpo_shared() -> NMPOAppDelegate {
        return UIApplication.shared.delegate as! NMPOAppDelegate
    }
}

